import Config from "../main.config";
import Ajax from "../utils/Ajax";
import {setStorageSync} from "../utils/Storage"
module.exports = {
    /*
    * 模糊查询企业信息
    * */
    getSearchList: async function (data) {
        let url = Config.api.enterpriseSearch;
        let res = await Ajax.request({
            method: "POST",
            url,
            data: data
        })
        return {
            count: res.count,
            data: res.data.map(function (item) {
                return {
                    id: item.id,
                    name: item.name
                }
            })
        }
    },

    /*
    * 获取企业注册详情
    * */
    getRegisterDetail: async function (data = {}) {
        let url = Config.api.enterpriseDetail;
        let res = await Ajax.request({
            method: "POST",
            url,
            data
        })
        data.createUser ? setStorageSync(Config.storage.registerInfo, res) : null;
        return res
    },

    /*
    * 创建企业
    * */
    createUser: async function (data) {
        let url = Config.api.enterpriseCreate;
        return await Ajax.request({
            method: "POST",
            url,
            data
        })
    },

    /*
    * 编辑
    * */
    editUser: async function (data) {
        let url = Config.api.enterpriseEdit;
        return await Ajax.request({
            method: "POST",
            url,
            data
        })
    }
}